package com.clothing.customization.controller.designer;

import com.clothing.customization.dto.ScheduleDTO;
import com.clothing.customization.dto.ScheduleQueryDTO;
import com.clothing.customization.service.ScheduleService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

@RestController
@RequestMapping("/api/designer/schedule")
@RequiredArgsConstructor
@PreAuthorize("hasRole('DESIGNER')")
public class ScheduleController {

    private final ScheduleService scheduleService;

    @GetMapping("/list")
    public Page<ScheduleDTO> getScheduleList(ScheduleQueryDTO queryDTO) {
        return scheduleService.getScheduleList(queryDTO);
    }

    @GetMapping("/{id}")
    public ScheduleDTO getScheduleDetail(@PathVariable Long id) {
        return scheduleService.getScheduleDetail(id);
    }

    @PostMapping
    public ScheduleDTO createSchedule(@Valid @RequestBody ScheduleDTO scheduleDTO) {
        return scheduleService.createSchedule(scheduleDTO);
    }

    @PutMapping("/{id}")
    public ScheduleDTO updateSchedule(@PathVariable Long id, @Valid @RequestBody ScheduleDTO scheduleDTO) {
        return scheduleService.updateSchedule(id, scheduleDTO);
    }

    @DeleteMapping("/{id}")
    public void deleteSchedule(@PathVariable Long id) {
        scheduleService.deleteSchedule(id);
    }

    @PutMapping("/{id}/status")
    public void updateScheduleStatus(@PathVariable Long id, @RequestParam String status) {
        scheduleService.updateScheduleStatus(id, status);
    }
} 